import request from '@/utils/request';

export function upload(data) {
  return request({
    url: '/txs/clerk/upload',
    method: 'post',
    data,
  });
}

export function getAlarms() {
  return request({
    url: '/txs/common/alarm',
    method: 'get',
  });
}

export function setAlarm(data) {
  return request({
    url: '/txs/common/alarm',
    method: 'post',
    data,
  });
}

export function delAlarm(id) {
  return request({
    url: '/txs/common/alarm/' + id,
    method: 'delete',
  });
}

export function uploadFile(data) {
  return request({
    url: '/txs/common/uploadfile',
    method: 'post',
    data,
  });
}

export function uploadCom(data) {
  return request({
    url: '/txs/common/upload',
    method: 'post',
    data,
  });
}

export function getReport(id) {
  return request({
    url: '/txs/clerk/rpt/' + id,
    method: 'get',
  });
}

export function getZiXunDanPic(id, zType) {
  return request({
    url: '/txs/clerk/zxdPic/' + id + '/' + zType,
    method: 'get',
  });
}

export function getZiXunDanPdf(id, zType) {
  return request({
    url: '/txs/clerk/zxdPdf/' + id + '/' + zType,
    method: 'get',
    responseType: 'blob',
  });
}

export function existZiXunDanAndCreate(id, zType) {
  return request({
    url: '/txs/clerk/zxdExist/' + id + '/' + zType,
    method: 'get',
  });
}

export function statSalonClerk() {
  return request({
    url: '/txs/clerk/statistics',
    method: 'get',
  });
}

export function getSimpleSalons() {
  return request({
    url: '/txs/salon/simple',
    method: 'get',
  });
}

export function getSpend(pageNumber, pageSize) {
  return request({
    url: '/txs/cost/spend',
    method: 'get',
    params: { pageNumber, pageSize },
  });
}

export function changeSpend(data) {
  return request({
    url: '/txs/cost/spend',
    method: 'put',
    data,
  });
}

export function changeStoreFrozen(id, data) {
  return request({
    url: '/txs/salon/froze/' + id,
    method: 'put',
    data,
  });
}

export function setSalonReplay(data) {
  return request({
    url: '/txs/salon/replay',
    method: 'post',
    data,
  });
}

export function getSalonReplay(sid, pageNumber, pageSize) {
  return request({
    url: '/txs/salon/replay/' + sid,
    method: 'get',
    params: { pageNumber, pageSize },
  });
}

export function getSomeSalon(status, sname, address, mname, developer, oid, sid) {
  return request({
    url: '/txs/salon/some/',
    method: 'get',
    params: { status, sname, address, mname, developer, oid, sid },
  });
}

export function getSnameSalon(sname) {
  return request({
    url: '/txs/salon/sname/',
    method: 'get',
    params: { sname },
  });
}

export function getSalon(id) {
  return request({
    url: '/txs/salon/' + id,
    method: 'get',
  });
}

export function getSalonList() {
  return request({
    url: '/txs/salon/all',
    method: 'get',
  });
}

export function AssignedBranchIds() {
  return request({
    url: '/txs/salon/branched',
    method: 'get',
  });
}

export function getSalonsByMid(mid) {
  return request({
    url: '/txs/salon/community/' + mid,
    method: 'get',
  });
}

export function getSalonList2(pageNumber, pageSize, sname, code, bid, oid) {
  return request({
    url: '/txs/salon',
    method: 'get',
    params: { pageNumber, pageSize, sname, code, bid, oid },
  });
}

export function addSalon(data) {
  return request({
    url: '/txs/salon',
    method: 'post',
    data,
  });
}

export function editSalon(data) {
  return request({
    url: '/txs/salon',
    method: 'put',
    data,
  });
}

export function delSalon(id) {
  return request({
    url: '/txs/salon/' + id,
    method: 'delete',
  });
}

export function getClerkList(pageNumber, pageSize, role, mid, status, sids, kid) {
  return request({
    url: '/txs/clerk/vo/' + status,
    method: 'get',
    params: { pageNumber, pageSize, role, mid, sids, kid },
  });
}

/**
 * 批量修改顾客的重点状态
 *
 * @param {number} noble 重点状态，0 or 2
 * @param {Array} ids 顾客ID列表
 * @return {Promise}
 */
export function batchUpdateNoble(noble, ids) {
  return request({
    url: `/txs/clerk/noble/batch/${noble}`,
    method: 'put',
    data: ids,
  });
}

/**
 * 批量改顾客的生日送礼状态
 *
 * @param {number} state 重点状态，0 or 1
 * @param {Array} ids 顾客ID列表
 * @return {Promise}
 */
export function batchUpdateBirthdayGift(state, ids) {
  return request({
    url: `/txs/clerk/gift/birthday/batch/${state}`,
    method: 'put',
    data: ids,
  });
}

/**
 * @param {number} status 状态? (后面加的注释)
 * @param {Object} params 其他查询参数
 * @return {Object}
 * @deprecated 使用 getClerkPageBySalonId
 */
export function getClerkPage(status, params) {
  return request({
    url: '/txs/clerk/vo/' + status,
    method: 'get',
    params: params,
  });
}

export function getClerks(sid) {
  return request({
    url: '/txs/clerk/salon/' + sid,
    method: 'get',
  });
}

export function getClerk(id) {
  return request({
    url: '/txs/clerk/' + id,
    method: 'get',
  });
}

export function applyNobleById(id, value) {
  return request({
    url: '/txs/clerk/noble/' + id,
    method: 'get',
    params: { value },
  });
}

export function getShopClerks(sid) {
  return request({
    url: '/txs/clerk/shop/' + sid,
    method: 'get',
  });
}

export function addClerk(data) {
  return request({
    url: '/txs/clerk',
    method: 'post',
    data,
  });
}

export function addClerk2(data) {
  return request({
    url: '/txs/clerk/add',
    method: 'post',
    data,
  });
}

export function uploadImages(data, cid) {
  return request({
    url: '/txs/clerk/imgs/' + cid,
    method: 'post',
    data,
  });
}

export function getImages(id) {
  return request({
    url: '/txs/clerk/images/' + id,
    method: 'get',
  });
}

export function countConsumerBySalons(data) {
  return request({
    url: '/txs/clerk/count/salons',
    method: 'put',
    data,
  });
}

export function countConsumerByKeepers(data) {
  return request({
    url: '/txs/clerk/count/keepers',
    method: 'put',
    data,
  });
}

export function editClerk(data) {
  return request({
    url: '/txs/clerk',
    method: 'put',
    data,
  });
}

export function setSeen(id) {
  return request({
    url: '/txs/clerk/see/' + id,
    method: 'put',
  });
}

export function assignKeeper4Consumer(data) {
  return request({
    url: '/txs/clerk/assign/keeper',
    method: 'put',
    data,
  });
}

/**
 * 根据门店ID, 分页查询顾客列表
 *
 * @param {Object} data
 * @return {Object}
 */
export function getClerkPageBySalonId(data) {
  return request({
    url: '/txs/clerk/salon/page',
    method: 'get',
    params: data,
  });
}

/**
 * 教练分页查询顾客列表
 *
 * @param {Object} data
 * @return {Object}
 */
export function getClerkPageByCoach(data) {
  return request({
    url: '/txs/clerk/coach/page',
    method: 'get',
    params: data,
  });
}

/**
 * 根据管家ID, 分页查询顾客列表
 *
 * @param {Object} data
 * @return {Object}
 */
export function getClerkPageByKeeperId(data) {
  return request({
    url: '/txs/clerk/keeper/page',
    method: 'get',
    params: data,
  });
}

/**
 * 根据门店ID, 分页查询当天过生日的顾客列表
 *
 * @param {Object} data
 * @return {Object}
 */
export function getClerkBirthdayTodayPageBySalonId(data) {
  return request({
    url: '/txs/clerk/salon/birthday/today/page',
    method: 'get',
    params: data,
  });
}

export function setClerkKeeper(data) {
  return request({
    url: '/txs/clerk/keeper',
    method: 'put',
    data,
  });
}

export function editClerkTag(data) {
  return request({
    url: '/txs/clerk/tag',
    method: 'put',
    data,
  });
}

export function delClerk(id) {
  return request({
    url: '/txs/clerk/' + id,
    method: 'delete',
  });
}

export function setReport(id, report, sname, ds, dj) {
  return request({
    url: '/txs/clerk/report/' + id,
    method: 'get',
    params: { report, sname, ds, dj },
  });
}

export function getWxTenGod(wx) {
  return request({
    url: '/txs/clerk/report/wx',
    method: 'get',
    params: { wx },
  });
}

export function getDiag(sid) {
  return request({
    url: '/txs/diag/' + sid,
    method: 'get',
  });
}

export function getKanyu(sid) {
  return request({
    url: '/txs/kanyu/' + sid,
    method: 'get',
  });
}

export function saveDiag(data) {
  return request({
    url: '/txs/diag',
    method: 'post',
    data,
  });
}

export function saveKanyu(data) {
  return request({
    url: '/txs/kanyu',
    method: 'post',
    data,
  });
}

export function getConclusion(sid) {
  return request({
    url: '/txs/report/' + sid,
    method: 'get',
  });
}

export function saveConclusion(data) {
  return request({
    url: '/txs/report',
    method: 'post',
    data,
  });
}

export function getSoldiers(sid) {
  return request({
    url: '/txs/report/soldier/' + sid,
    method: 'get',
  });
}

export function saveSoldier(data) {
  return request({
    url: '/txs/report/soldier',
    method: 'post',
    data,
  });
}

export function delSoldier(id) {
  return request({
    url: '/txs/report/soldier/' + id,
    method: 'delete',
  });
}

export function updateTags(id, kq, sj, qt, track) {
  return request({
    url: '/txs/clerk/tag-sj/' + id,
    method: 'get',
    params: { kq, sj, qt, track },
  });
}

export function updateSpend(id, spend) {
  return request({
    url: '/txs/clerk/spend/' + id,
    method: 'get',
    params: { spend },
  });
}

export function updateTrack(id, track) {
  return request({
    url: '/txs/salon/track/' + id,
    method: 'get',
    params: { track },
  });
}

export function updateAlarm(id, alarm) {
  return request({
    url: '/txs/salon/alarm/' + id,
    method: 'get',
    params: { alarm },
  });
}

// export function getSomeClerk(reason, begin, end) {
//   return request({
//     url: '/txs/clerk/some',
//     method: 'get',
//     params: { reason, begin, end }
//   })
// }

export function updateTrust(id, data) {
  return request({
    url: '/txs/clerk/trust/' + id,
    method: 'put',
    data,
  });
}

export function getSomeClerk(sname, cname, ccode, kname, mid, role) {
  return request({
    url: '/txs/clerk/some',
    method: 'get',
    params: { sname, cname, ccode, kname, mid, role },
  });
}

export function getSearchClerk(sname, isApply, isNew, mid, role, dj, rmk, trust, isTrust) {
  return request({
    url: '/txs/clerk/search',
    method: 'get',
    params: { sname, isApply, isNew, mid, role, dj, rmk, trust, isTrust },
  });
}

export function searchConsumersBySids(sname, cname, ccode, kname, sids) {
  return request({
    url: '/txs/clerk/some/sids',
    method: 'get',
    params: { sname, cname, ccode, kname, sids },
  });
}

export function getBigb(id) {
  return request({
    url: '/txs/bigb/' + id,
    method: 'get',
  });
}

export function getBigbs() {
  return request({
    url: '/txs/bigb',
    method: 'get',
  });
}

export function addBigb(data) {
  return request({
    url: '/txs/bigb',
    method: 'post',
    data,
  });
}

export function editBigb(data) {
  return request({
    url: '/txs/bigb',
    method: 'put',
    data,
  });
}

export function updateChecked(id) {
  return request({
    url: '/txs/clerk/check/' + id,
    method: 'put',
  });
}

export function updateBigbTrack(id, track) {
  return request({
    url: '/txs/bigb/track/' + id,
    method: 'get',
    params: { track },
  });
}

export function delBigb(id) {
  return request({
    url: '/txs/bigb/' + id,
    method: 'delete',
  });
}
